package tmi.li.txwthrsmall;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class ColorConfigActivity extends Activity{ 
	@Override
    public void onCreate(Bundle savedInstanceState) {    	
        super.onCreate(savedInstanceState);
        setContentView(R.layout.color_activity);
        TextView ed = (TextView)findViewById(R.id.elFColorPreview);
        ed.setOnLongClickListener(openDialog);
        ed = (TextView)findViewById(R.id.eTFColorPreview);
        ed.setOnLongClickListener(openDialog);
        ed = (TextView)findViewById(R.id.eBFColorPreview);
        ed.setOnLongClickListener(openDialog);
        ed = (TextView)findViewById(R.id.eBColorPreview);
        ed.setOnLongClickListener(openDialog);
        
        Button save = (Button)findViewById(R.id.csave);
        save.setOnClickListener(new View.OnClickListener() {	
			public void onClick(View v) {
				if(saveOptions(v.getContext()))
					finish();
			}
		});
    }
	
	View.OnLongClickListener openDialog = new View.OnLongClickListener() {
		
		public boolean onLongClick(View v) {
			final int id = v.getId();
			final ColorPickerDialog clr = new ColorPickerDialog(v.getContext());
			clr.onSaveClicked = new View.OnClickListener() {
				
				public void onClick(View v) {
					EditText ed = (EditText)findViewById(id-1);
					ed.setText(clr.getColorHex());
					TextView view = (TextView)findViewById(id);
					view.setBackgroundColor(clr.getColor());
					clr.dismiss();
				}
			};
			clr.show();
			return false;
		}
	};
	
	
	public boolean saveOptions(Context context) {
		return true;
	}
    

}
